<template>
  <div id="app">
    <header>TabBar案例</header>
    <section>
      <keep-alive>
        <!-- <component :is="currentPage" /> -->
        <router-view></router-view>
      </keep-alive>
    </section>
    <nav>
      <div
        class="tab-item"
        v-for="item in tabList"
        :key="item.key"
        @click="go(item.key)"
      >
        <div class="icon">{{ item.icon }}</div>
        <div class="nav-title">{{ item.title }}</div>
      </div>
    </nav>
  </div>
</template>

<script>
export default {
  name: 'App',
  data () {
    return {
      // currentPage: 'GoodsList',
      tabList: [
        {
          icon: 'x',
          title: '商品列表',
          key: 'goods-list',
        },
        {
          icon: 'x',
          title: '商品搜索',
          key: 'goods-search',
        },
        {
          icon: 'x',
          title: '我的信息',
          key: 'my-info',
        },
      ],
    };
  },
  methods: {
    go (path) {
      this.$router.push(path);
    },
  },
}
</script>

<style>
#app {
  height: 100vh;
  display: flex;
  flex-direction: column;
}
header {
  height: 50px;
  text-align: center;
  line-height: 50px;
  color: #fff;
  background: skyblue;
}
section {
  flex: 1;
  overflow-y: auto;
}
nav {
  height: 60px;
  display: flex;
  justify-content: space-around;
  align-items: center;
  box-shadow: 0 -3px 3px #aaa;
}
.tab-item {
  display: flex;
  flex-direction: column;
  align-items: center;
}
</style>